#include using namespace std; void fun(int x) { x = 99; cout << x << endl; } //x is, in this function, is a reference to an integer //reference = nickname or psuedoname void funRef(int& x) { x = 77; cout << x << endl; } void trade(int& x, int& y) { int z = x; x = y; y = z; } int Max(int x, int y) { int result = x; if (y > x) { result = y; } return result; } void GetMax(int x, int y, int& result) { result = x; if (y > x) { result = y; } } void Square(int& n) { n = n * n; } //prototype void Cube(int& n); void main() { int y = 88; //the variable y is passed to the function fun "by value" aka "by copy" fun(y); cout << y << endl; //the variable y is passed to the function fun "by reference" aka "by address" funRef(y); cout << y << endl; int i = 1; int j = 2; trade(i, j); cout << "i = " << i << endl; cout << "j = " << j << endl; int k; k = Max(i, j); cout << k << endl; GetMax(i, j, k); cout << k << endl; Square(k); cout << k << endl; } void Cube(int& n) { n = n * n * n; }